﻿using System.Collections.Generic;
using Ayatta.Contract.Domain;

namespace Ayatta.Contract.Extension
{
    public static class GameExtension
    {
        public static IList<GameServer> GetAllServers(this IList<Game> games, bool includeGame = false)
        {
            var servers = new List<GameServer>();
            if (games != null)
            {
                foreach (var o in games)
                {
                    if (includeGame)
                    {
                        foreach (var server in o.Servers)
                        {
                            var temp = server;
                            server.Game = o;
                            servers.Add(temp);
                        }
                    }
                    else
                    {
                        servers.AddRange(o.Servers);
                    }
                }
            }
            return servers;
        }

    }
}